package com.iring.service.common.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iring.dao.common.view.CountryViewDao;
import com.iring.domain.common.view.CountryView;
import com.iring.service.common.CountryViewService;
import com.iring.vo.common.CountryVO;


/**
 * 查询通话记录dao
 *
 * @author wanggan
 */

@Service
public class CountryViewServiceImpl implements CountryViewService {

    @Autowired
    CountryViewDao countryViewDao;


    @Override
    public List<CountryVO> listAllCountry() {
        List<CountryView> countryViewList = countryViewDao.findAll();

        List<CountryVO> countryVOList = new ArrayList<>();
        countryViewList.stream()
                .forEach(index->{
                    CountryVO countryVO = new CountryVO();
                    countryVO.setId(index.getId());
                    countryVO.setCode(index.getCode());
                    List<String> country = new ArrayList<>();
                    country.add(index.getCnname());
                    country.add(index.getEnname());
                    countryVO.setCountry(country);
                    countryVOList.add(countryVO);

                });
        return countryVOList;
    }


}
